/**
 *
 */
package com.angel.email.attachments.strategies.impl.simple;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

import javax.activation.DataHandler;
import javax.mail.Part;

import com.angel.common.keyValue.KeyValueResult;
import com.angel.email.attachments.EmailAttachmentInfo;
import com.angel.email.attachments.strategies.AttachmentsStrategy;
import com.angel.email.exceptions.EmailAccessException;
import com.angel.email.exceptions.EmailAttachmentException;
import com.angel.webapp.file.FileInformation;



/**
 * @author William
 * @since 14/August/2009
 *
 */
public class PlainTextAttachmentStrategy implements AttachmentsStrategy{

	public FileInformation getAttachmentFrom(DataHandler dataHandler) throws EmailAccessException{
		FileInformation fi = null;
		try {
			InputStream inputStream = dataHandler.getInputStream();
			fi = new EmailAttachmentInfo
				(
					dataHandler.getContentType(),
					dataHandler.getName(),
					inputStream,
					0
				);
		} catch (IOException e) {
			throw new EmailAccessException("Error during writing / closing content.", e);
		}
		return fi;
	}

	public List<FileInformation> getAttachmentsFrom(DataHandler dataHandler,
			KeyValueResult attachmentsStrategies)
			throws EmailAttachmentException {
		// TODO Auto-generated method stub
		return null;
	}

	public FileInformation getAttachmentsFrom(Part part,
			KeyValueResult attachmentsStrategies)
			throws EmailAttachmentException {
		// TODO Auto-generated method stub
		return null;
	}
}
